import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 沈明月
 * Date: 2022-11-02
 * Time: 15:03
 */
public class KnowledgeOne {
//通过方法来判断闰年：
    public static boolean isLeapYear(int year){
        if((0==year%4&&0!=year%100)||0==year%400){
            System.out.println(year+"年是闰年！");
            return true;
        }else{
            System.out.println(year+"年不是闰年！");
            return false;
        }
    }
    public static void main1(String[] args) {
        isLeapYear(2022);//调用方法
    }

//通过方法来实现两数相加
    public  static  int add(int a,int b){//形参
        return a+b;
    }
    public static void main2(String[] args) {

        int ret1 = add(1,34);//实参
        System.out.println(ret1);

        int a=10;
        int b=36;
        int ret2=add(a,b);
        System.out.println(ret2);
    }

//求阶乘和
    public static void main3(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 7; i++) {
            int ret=1;
            for (int j = 1; j <= i; j++) {
                ret *= j;
            }
            sum +=ret;
        }
        System.out.println(sum);
    }

//分装成函数：
    public static void main4(String[] args) {

    }

//方法重载：方法名称可以一样，但是其参数列表不同（数据类型不一样、或参数个数、或参数顺序）不一样，和返回类型无关
    public  static  int sum(int a,int b){
        return a+b;
    }
    public static int sum(int a,int b,int c){
        return a+b+c;
    }
    public static double sum(double a, double b){
        return a+b;
    }
    public static void main5(String[] args) {
        int a=10;
        int b=21;
        int c=23;
        int ret1 = sum(a,b);
        System.out.println(ret1);

        int ret2 = sum(a,b,c);
        System.out.println(ret2);

        double d=12.2;
        double e=13.2;
        double ret3=sum(a,b);
        System.out.println(ret3);
    }
}
